package genericity_try;

public class GenericClassBox<T extends Number> {
    private final T length;
    private final T wide;
    private final T height;

    GenericClassBox(T l, T w, T h){
        length = l;
        wide = w;
        height = h;
    }

    public double Area(){
        return length.doubleValue()*wide.doubleValue()*height.doubleValue();
    }

    public T getHeight() {
        return height;
    }

    public T getLength() {
        return length;
    }

    public T getWide() {
        return wide;
    }

    public static void main(String[] args) {
        GenericClassBox<Number> box = new GenericClassBox<>(3.2, 2, 4); //菱形语法是Java 7引入的一个特性，它允许在实例化泛型类时省略类型参数，由编译器进行类型推断。
        System.out.println(box.Area());
    }
}
